package org.example.Day2.Student;

import java.util.ArrayList;

public class StudentOperateImpl2 implements StudentOperator{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("-----全班同学信息如下-----");
        int count1 = 0;
        int count2 = 0;

        for(int i=0;i<students.size();i++){
            Student s =students.get(i);
            System.out.println("姓名:"+s.getName()+"，性别:"+s.getSex()+",成绩:"+s.getScore());
            if(s.getSex()=='男'){
                count1++;
            }else{
                count2++;
            }

        }
        System.out.println("男⽣⼈数是：" + count1 + ", ⼥⼠⼈数是：" + count2);
        System.out.println("班级总人数为:"+students.size());
        System.out.println("-------------------");


    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double allscore = 0.0;
        double max = students.get(0).getScore();
        double min = students.get(0).getScore();
        for(int i=0;i<students.size();i++){
            Student s = students.get(i);
            if(s.getScore()>max){
                max = s.getScore();
            }
            if(s.getScore()<min){
                min = s.getScore();
            }
            allscore += s.getScore();
        }
        System.out.println("班级最高分为:"+max);
        System.out.println("班级最低分为:"+min);
        System.out.println("去掉一个最高分最低分后班级的平均分为:"+(allscore-max-min)/(students.size()-2));
    }
}
